package cn.com.callback

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import cn.com.elite.EliteBean;
import cn.com.elite.PropertiesUtil;
import cn.com.elite.Util;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.sf.json.JSONObject;

/**
 * @author ThinkPad
 */

public class ecservlet implements ServiceBackInvoke {
    private static final Log log = LogFactory.getLog(ecservlet.class);

    public String doCallBack(EliteBean eliteBean, HttpServletRequest request, HttpServletResponse response) {
        PropertiesUtil properties = new PropertiesUtil();
        def ecservletip = properties.readValue("ecservletip"); //获取配置文件ec接口IP
        def crmservletip = properties.readValue("crmservletip");//获取配置文件CRM接口IP
        def ecsecretkey = properties.readValue("ecsecretkey");//获取配置文件ec接口加密Key
        def receivebody = Util.getRequestBody(request, 'utf-8'); //获取报文
        JSONObject obj = JSONObject.fromObject(receivebody);
        obj.put("secretkey", ecsecretkey);
        def url = crmservletip + "/ensign";
        def charset = "utf-8";
        def timeout = 100000;
        def enableSSLflag = 0;
        def requestinfo = Util.doHttpPost(url, JSONObject.fromObject(obj).toString(), charset, timeout, enableSSLflag);
        return Util.doHttpPost(ecservletip, requestinfo, charset, timeout, enableSSLflag);
    }
}